//
//  CustomImgView.m
//  EducationAdminClient
//
//  Created by kwsdzjx on 16/8/12.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "CustomImgView.h"
#import "Masonry.h"
#import "UIColor+CL.h"

@implementation CustomImgView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        UIView *view = [self createUI];
        [self addSubview:view];
        UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self).insets(edge);
        }];
        
        view.backgroundColor = [UIColor redColor];
    }
    
    return self;
}

-(UIView *)createUI{
    UIView *baseView = [[UIView alloc]init];
    _imageView = [[UIImageView alloc]init];
    [baseView addSubview:_imageView];
    
    _label = [[UILabel alloc]init];
    [baseView addSubview:_label];
    
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseView.mas_left);
        make.top.equalTo(baseView.mas_top);
        make.right.equalTo(baseView.mas_right);
        make.bottom.equalTo(baseView.mas_bottom).offset(-194/2);
    }];
    _imageView.backgroundColor = [UIColor blueColor];
    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageView.mas_left);
        make.top.equalTo(_imageView.mas_bottom);
        make.right.equalTo(_imageView.mas_right);
        make.bottom.equalTo(baseView.mas_bottom);
    }];
    
    _label.font = [UIFont systemFontOfSize:48/2];
    _label.textAlignment = NSTextAlignmentCenter;
    _label.textColor = [UIColor colorWithHex:0x333333];
    _label.backgroundColor = [UIColor colorWithHex:0xececec];
    return baseView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
